package cur.nature.admin.controller;

import cur.nature.admin.service.Admin_RoleService;
import cur.nature.framework.mvc.base.BaseAPI;
import cur.nature.framework.mvc.crud.CrudController;
import cur.nature.admin.model.vo.Admin_RoleVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户角色 Controller
 * 作者：Auto Generator By wujian
 * 生成日期：2023-07-10 21:42:14
 */
@Tag(name = "用户角色 接口")
@RestController
@RequestMapping("admin/v1/api/Admin_Role")
public class Admin_RoleController extends CrudController<Admin_RoleService> {
    public Admin_RoleController(Admin_RoleService baseService) {
        super(baseService);
    }

    @Operation(summary = "查询 用户角色")
    @PostMapping("/list")
    public Admin_RoleVO.list_Result list(@Valid @RequestBody Admin_RoleVO.list_Param param) throws Exception {
        Admin_RoleVO.list_Result list = getService().list(param);
        return list;
    }

    @Operation(summary = "更新 用户角色")
    @PostMapping("/operate")
    public BaseAPI.SaveResult<Admin_RoleVO> save(@Valid @RequestBody List<Admin_RoleVO> param) throws Exception {
        int rows = getService().operate(param);
        BaseAPI.SaveResult result = new BaseAPI.SaveResult();
        result.setRows(rows);
        result.setObject(rows == 0 ? null : param);
        return result;
    }

}

